<%@ Page Language="VB" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="false" CodeFile="SpecialFields.aspx.vb" Inherits="SpecialFields" title="Admin - Special Fields" %>
<%@ Register Assembly="InputControls" Namespace="InputControls" TagPrefix="cc2" %>
<%@ Register Src="SubNavControls/FieldsSubNavControl.ascx" TagName="FieldsSubNavControl" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<uc1:FieldsSubNavControl ID="SubNavCtrl" runat="server" />
  <asp:ObjectDataSource ID="AdminTableObjectDataSource" runat="server" DataObjectTypeName="Cdm.DataCore.LookupTables.LuAdminTableList"
        DeleteMethod="RemoveInstance" InsertMethod="SaveInstance" SelectMethod="ListSpecialFieldTables"
        TypeName="Cdm.DataCore.LookupTables.LuAdminTableList" UpdateMethod="UpdateInstance">
    </asp:ObjectDataSource>
    
    <asp:ObjectDataSource ID="SpecialFieldObjectDataSource" runat="server" SelectMethod="ListByTable" SortParameterName="sortExpr" DeleteMethod="RemoveInstance"
        TypeName="Cdm.DataCore.Admin.AdminSpecialField" DataObjectTypeName="Cdm.DataCore.Admin.AdminSpecialField" UpdateMethod="UpdateInstance" InsertMethod="SaveInstance">
        <SelectParameters>
            <asp:ControlParameter ControlID="SelectFormDropDownList" DefaultValue="" Name="TableID"
                PropertyName="SelectedValue" Type="Int32" />
            <asp:ControlParameter ControlID="ActiveOnlyCheckBox" Name="activeOnly" PropertyName="Checked" />
        </SelectParameters>
    </asp:ObjectDataSource>

  
    <table cellpadding="0" cellspacing="0">
<tr><td style="width:20px;" rowspan="5"></td>
<td><h1><a id="pagecontent">Admin - Special Fields</a></h1></td>
        <td align="center" style="width:200px;"><asp:CheckBox ID="ActiveOnlyCheckBox" runat="server" CssClass="adminSelectLabel" AutoPostBack="True" Text="Show Active Only" /></td>
        <td align="right" style="width:300px;"><asp:Label ID="ScreenFormLabel" runat="server" AssociatedControlID="SelectFormDropDownList" Text="Select Screen:" CssClass="adminSelectLabel"></asp:Label>
    <asp:DropDownList ID="SelectFormDropDownList" runat="server" CssClass="adminSelectForm" DataSourceID="AdminTableObjectDataSource" DataTextField="TableName" DataValueField="TableId" AutoPostBack="false"></asp:DropDownList>
    <asp:Button ID="SubmitFormSelectButton" runat="server" Text="Go" /></td></tr>
    <tr><td colspan="3" align="center"><cc2:ValidationErrorSummary ID="ErrorSummary" runat="server" Message="" Visible="false" /></td></tr>
    <tr><td colspan="3" align="center"> 
    <cc2:ScrollingGridView ID="SpecialFieldsScrollingGridView" runat="server" CssClass="gridOffset" IsFixedColumn="true" AutoGenerateColumns="False" Caption="Create state-specific fields."  DataSourceID="SpecialFieldObjectDataSource" DataKeyNames="SpecialFieldID,TableID" CellPadding="5" BorderColor="#21334B" 
                BorderStyle="Solid" GridLines="Vertical" EmptyDataText="No data.  Click the <b>Add</b> button below to add an item." AllowSorting="true">
        <HeaderStyle  CssClass="adminHeaderStyle" BackColor="#C3CAD4" BorderColor="#21334B" VerticalAlign="Top" />
        <RowStyle CssClass="adminColumnStyle" />
        <Columns>
        <asp:TemplateField HeaderText="Field Name" SortExpression="FieldName">
        <ItemStyle HorizontalAlign="left" Width="185px" />
            <HeaderStyle Width="200px" />
            <ItemTemplate>
                <%#Eval("FieldName")%>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="EditFieldNameTextBox" Text='<%#Bind("FieldName") %>' ToolTip="edit field name"></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Field Type" SortExpression="FieldTypeId">
        <ItemStyle HorizontalAlign="center" Width="100px" />
            <HeaderStyle Width="100px" />
            <ItemTemplate>
                <%#DisplayFieldType(Eval("FieldTypeId"))%>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList ID="EditFieldTypeDropDownList" runat="server" AutoPostBack="false" SelectedValue='<%#Bind("FieldTypeId")%>' DataSource='<%# FieldTypeList() %>' DataTextField="FieldTypeName" DataValueField="FieldTypeId" ToolTip="edit field type"></asp:DropDownList>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Active" SortExpression="IsActive">
        <ItemStyle HorizontalAlign="center" Width="80px" />
            <HeaderStyle Width="80px" />
            <ItemTemplate>
                <asp:CheckBox ID="EditActiveCheckBox" runat="server" Checked='<%# Bind("IsActive") %>' Enabled="False"></asp:CheckBox>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="center" />
            <EditItemTemplate>
                <asp:CheckBox ID="EditActiveCheckBox" runat="server" Checked='<%# Bind("IsActive") %>' ToolTip="check if field is active" />
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Required" SortExpression="IsRequired">
            <ItemTemplate>
                <asp:CheckBox ID="EditRequiredCheckBox" runat="server" Checked='<%# Bind("IsRequired") %>' Enabled="False"></asp:CheckBox>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="center" Width="80px" />
            <HeaderStyle Width="80px" />
            <EditItemTemplate>
                <asp:CheckBox ID="EditRequiredCheckBox" runat="server" Checked='<%# Bind("IsRequired") %>' ToolTip="check to make field required" />
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Display Order" SortExpression="DisplayOrder">
        <ItemStyle Width="80px" />
        <HeaderStyle Width="80px" />
            <ItemTemplate><%#Eval("DisplayOrder")%>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="EditDisplayOrderTextBox" runat="server" Text='<%# Bind("DisplayOrder") %>' ToolTip="edit display order" />
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <ItemStyle HorizontalAlign="center" Width="80px" />
            <HeaderStyle Width="80px" />
            <ItemTemplate><%#Eval("ListItemsLink")%></ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:Linkbutton ID="DeleteButton" CommandName="Delete" CommandArgument='<%# Eval("SpecialFieldID") %>' runat="server" Text="Delete"></asp:Linkbutton>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Center" Width="65px" />
            <HeaderStyle Width="65px" />
            
        </asp:TemplateField>
        <asp:CommandField ShowEditButton="True" HeaderText="Action" AccessibleHeaderText="Action">
            <ItemStyle HorizontalAlign="Center" Width="85px" />
            <HeaderStyle Width="115px" />
        </asp:CommandField>
        </Columns>
        <AlternatingRowStyle BackColor="#E8ECF4" />
        <EmptyDataRowStyle CssClass="headerStyle" BackColor="#C3CAD4" /></cc2:ScrollingGridView>
    </td></tr>
    <tr><td colspan="3" align="center">
            <asp:FormView ID="SpecialFieldsFormView" runat="server" BackColor="white" DataKeyNames="SpecialFieldID"
            DataSourceID="SpecialFieldObjectDataSource" DefaultMode="Insert" Width="625px" Visible="False">
    <ItemTemplate>
    </ItemTemplate>
    <InsertItemTemplate>
        <table width="500px">
            <tr>
                <td><asp:Label ID="FieldNameLabel" runat="server" AssociatedControlID="FieldNameTextBox" Text="Field Name"></asp:Label></td>
                <td><asp:Label ID="FieldTypeLabel" runat="server" AssociatedControlID="FieldTypeDropDownList" Text="Field Type"></asp:Label></td>
                <td><asp:Label ID="ActiveLabel" runat="server" AssociatedControlID="ActiveCheckBox" Text="Active?"></asp:Label></td>
                <td><asp:Label ID="RequiredLabel" runat="server" AssociatedControlID="RequiredCheckBox" Text="Required?"></asp:Label></td>
                <td><asp:Label ID="DisplayOrderLabel" runat="server" AssociatedControlID="DisplayOrderTextBox" Text="Display Order"></asp:Label></td>
            </tr>
            <tr>
                <td><asp:TextBox ID="FieldNameTextBox" runat="server" Text='' MaxLength="30" Width="100px" /></td>
                <td><asp:DropDownList ID="FieldTypeDropDownList" runat="server" AutoPostBack="false"  DataSource="<%# FieldTypeList() %>" DataTextField="FieldTypeName" DataValueField="FieldTypeId" ></asp:DropDownList></td>
                <td><asp:CheckBox ID="ActiveCheckBox" runat="server"  /></td>
                <td><asp:CheckBox ID="RequiredCheckBox" runat="server" /></td>
                <td><asp:TextBox ID="DisplayOrderTextBox" runat="server" Width="40px" /></td>
            </tr>
        </table>
    </InsertItemTemplate>
    </asp:FormView>

    </td></tr>
    </table>
    
</asp:Content>
<asp:Content ID="FixedContent" ContentPlaceHolderID="ContentPlaceHolderFixedAdmin" runat="server">
    <asp:Button ID="SaveButton" runat="server" Text="Submit" Visible="false" />
    <asp:Button ID="CancelButton" runat="server" Text="Cancel" Visible="false" />
           <asp:Button ID="AddButton" runat="server" Text="Add" />
</asp:Content>

